﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RaytracerLib.Script;
using System.ComponentModel;
using System.Drawing;
using RaytracerLib.MathLib;

namespace Raytracer.PropertyGridDecorators
{
    public abstract class ScriptParamProperties
    {
        protected ScriptParam m_param;

        public ScriptParamProperties(ScriptParam a_param)
        {
            m_param = a_param;
        }

        public string Name
        {
            get
            {
                return m_param.Name;
            }
        }
    }

    public class ScriptParamColorFloatProperties : ScriptParamProperties
    {
        public ScriptParamColorFloatProperties(ScriptParam a_param)
            : base(a_param)
        {
        }

        [DisplayName("System color")]
        public Color SystemColor
        {
            get
            {
                return ((ColorFloat)m_param.Value).SystemColor;
            }
            set
            {
                m_param.Value = new ColorFloat(value);
            }
        }

        [TypeConverter(typeof(ColorFloatConverter))]
        public ColorFloatProperties Color
        {
            get
            {
                return new ColorFloatProperties(
                    () => (ColorFloat)m_param.Value,
                    (c) => m_param.Value = c);
            }
            set
            {
                m_param.Value = value.ToColorFloat();
            }
        }
    }

    public class ScriptParamDoubleProperties : ScriptParamProperties
    {
        public ScriptParamDoubleProperties(ScriptParam a_param)
            : base(a_param)
        {
        }

        [TypeConverter(typeof(DoubleConverter))]
        public double Value
        {
            get
            {
                return (double)m_param.Value;
            }
            set
            {
                m_param.Value = value;
            }
        }
    }
}
